package org.wkg.lesson02;

public class Demo_203 {
    public static void main(String[] args) {
        Thread thread1 = new Thread(() -> {
            while (true) {
                System.out.println(Thread.currentThread().getName() + " hello thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        //thread.start();


        Thread thread2 = new Thread(() -> {
            while (true) {
                //获取类名
                String cName = Demo_203.class.getName();
                //获取当前执行的方法名
                String mName = Thread.currentThread().getStackTrace()[1].getMethodName();
                Thread thread = Thread.currentThread();
                //获取线程名
                String tName = Thread.currentThread().getName();
                System.out.println("当前类: " + cName + " 当前方法: " + mName + " 当前进程: " + tName);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread2.start();
    }
}
